{% extends "layout.html" %}
{% block __data_browser__custom_external_block %}
  <script type="text/javascript">
    $(function () {
      $("#delete-button").click(function () {
        if (confirm("确定删除该卸货任务？")) {
          var form = $(this).parents("form");
          var input = $("<input type='hidden' name='action'></input>").val("delete");
          form.append(input).submit();
        } else {
          return false;
        }
      })
    });
  </script>
{% endblock %}
{% block body %}
  <div class="container">
    <div class="alert alert-info">
      车辆
      {{ task.delivery_session.plate }}
      {% if task.store_bill_list[0].harbor %}在装货点
        {{ task.store_bill_list[0].harbor.name }}{% endif %}
      完成了一次客户
      {{ task.customer.name }}
      的装货任务
    </div>
    <form class="form-horizontal" method="POST">
      <legend>发货任务详情</legend>
      <div class="form-group">
        <label class="control-label col-lg-2">产品名称</label>

        <div class="col-lg-3">
          <p class="form-control-static">{{ task.product.name }}</p>
        </div>
      </div>

      <div class="form-group">
        <label class="control-label col-lg-2">上次称重重量(公斤)</label>

        <div class="col-lg-3">
          <p class="form-control-static">{{ task.last_weight }}</p>
        </div>
      </div>
      <div class="form-group">
        <label class="control-label col-lg-2">上次称重时车上有人</label>

        <div class="col-lg-3">
          <p class="form-control-static">{{ task.delivery_session.with_person_des }}</p>
        </div>
      </div>
      <div class="form-group">
        <label for="weight" class="control-label col-lg-2">本次称重的重量为(公斤)</label>

        <div class="col-lg-3">
          <input type="number" name="weight" id="weight" size="20" required="True" min="{{ task.last_weight + 1 }}" class="form-control"/>
        </div>
      </div>
      <div class="form-group">
        <label class="control-label col-lg-2">此次装货的图片</label>

        <div class="col-lg-3">
          <ul class="list-group">
            {% for id, pic_url in task.pic_url_list %}
              {% if pic_url %}
                <li class="list-group-item">
                  <a href="{{ pic_url }}" class="fancybox" rel="group" title="{{ id }}-{{ task.product.name }}">
                    <img src="{{ pic_url }}" class="img-polaroid img-responsive" alt="{{ id }}-'{{ task.product.name }}"/>
                  </a>
                </li>
              {% endif %}
            {% endfor %}
          </ul>
        </div>
      </div>
      <div class="form-group">
        <div class="col-lg-10 col-lg-offset-2">
          <input type="hidden" name="url" value="{{ request.args.get("url") or url_for("delivery.delivery_session", id_=task.delivery_session.id) }}">

          <button class="btn btn-primary btn-lg"><i class="fa fa-save fa-fw"></i>保存</button>

          <a class="btn btn-lg btn-default" href="{{ request.args.get("url") or url_for("delivery.delivery_session", id_=task.delivery_session.id) }}">
            <i class="fa fa-backward fa-fw"></i>返回
          </a>
          <button class="btn btn-danger btn-lg" id="delete-button" type="button" >
            <i class="fa fa-times fa-fw"></i>删除
          </button>
        </div>
      </div>
    </form>
  </div>

{% endblock %}
